jQuery(function($){
    
    $('#settings a.backgroundChanger').each(function(){
        $(this).css('background',$(this).attr('href'));
    });
    $('#settings a.backgroundChanger').unbind('click').click(function(){
        $('#settings a.backgroundChanger').removeClass('active'); 
        $(this).addClass('active'); 
        $('#sidebar img').each(function(){
            $(this).attr('src', $(this).attr('src').replace('/dark/','/')  );
        });
        if($(this).hasClass('dark')){
            $('body').addClass('dark'); 
            $('#sidebar').attr('class','black'); 
        }else{
            $('body').removeClass('dark'); 
            $('#sidebar').attr('class','grey'); 
        }
        var link = $(this).attr('href'); 
        $('body').css('background',link);
        return false;
    });
    
    
    $('#settings a.blocChanger').unbind('click').click(function(){
        $('#settings a.blocChanger').removeClass('active'); 
        $(this).addClass('active'); 
        $('#content').attr('class',$(this).attr('href')); 
        return false;
    });
    
    
    $('#settings a.sidebarChanger').unbind('click').click(function(){
        $('#settings a.sidebarChanger').removeClass('active'); 
        $(this).addClass('active'); 
        $('#sidebar').attr('class',$(this).attr('href')); 
        if($(this).attr('href')=='white'){
            $('#sidebar img').each(function(){
                $(this).attr('src', $(this).attr('src').replace('/menu/','/menu/dark/')  );
            }); 
        }else{
            $('#sidebar img').each(function(){
                $(this).attr('src', $(this).attr('src').replace('/dark/','/')  );
            });
        }
        return false;
    });
    
    $('#settings').css('marginRight',-150);
    var toggled = false; 
    $('#settings a.settingbutton').click(function(){
        if(toggled){
            $('#settings').animate({marginRight:-$('#settings').width()},500);
        }else{
            $('#settings').animate({marginRight:0},500);
        }
        toggled = !toggled; 
        return false
    });
    
}); 



//定义空间名
Gootop = {};

Gootop.param = {
	bodyWidth:0,
	contentWidth:0,
	gridBarH:0,
	pl:30
};

//数据分页操作按键
Gootop.addDataGridOp = function(){};

Gootop.addTreeGridOp = function(){};

Gootop.resizeGPH = function(){};

Gootop.resizeGP = function(){};

Gootop.resize = function(){
	var cwidth = jQuery('#content').width()-2;
	if(cwidth != Gootop.param.contentWidth){
		Gootop.param.contentWidth = cwidth;
		Gootop.resizeGP();
	};
};

Gootop.loadComplete = function(){};

Gootop.dialogSearchAction = function(url){
	if( datecheck()){
		var target =jQuery("#grid_page"); 
		var data=jQuery("#search_form").serializeObject();
		var pd =target.jqGrid('getGridParam'); 
		data._search=true;
		data.rows=pd.rowNum;
		//搜索
		target.jqGrid('appendPostData',data);
		target.jqGrid('setGridParam',{url:url}).trigger("reloadGrid");
	}
};

toggled = true;
Gootop.showSearchBar = function(){
  if(toggled){
  	jQuery('#search_bar').slideDown(100);
  }else{
  	jQuery('#search_bar').slideUp();
  }
  toggled = !toggled; 
  return false
};

Gootop.deleteData = function(c){
	jQuery("#grid_page").jqGrid('setGridParam',{'editurl':'someurl.php'});
	jQuery("#grid_page").jqGrid('delGridRow',c,{reloadAfterSubmit:false});
};

jQuery().ready(function(){
	Gootop.param.contentWidth = jQuery('#content').width()-2;
});
jQuery(window).wresize(function(){
	Gootop.resize();
});

var O2String = function (O) {
       return JSON.stringify(O);
};